const users = require("../../sql/users");
const sql = require('../../sql/mysql');
const staff = require('../../sql/staffs');
module.exports =  (req,res)=>{
  const un = req.fields.username;
  const pw = req.fields.password;
    sql.get(users,{username:un}).then(data=>{
        if(data.length>0){
           res.send({code:1,msg:"账号重复"})
        }else{
            const date =""+ new Date().getFullYear()+"-" + (new Date().getMonth() +1) +"-"+ new Date().getDate() 
            req.fields.createTime = date;
            
            sql.add(staff,req.fields).then(()=>{
                // sql.add(users,{username:un,password:pw,roles:["breeder"]})
                res.send({code:0,msg:"添加成功"})
            })
        }
    })


}